<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.util.*, common.selectMenu"%>
<%
	session.setAttribute("stage", "2");
	request.setCharacterEncoding("UTF-8");
%>
<jsp:include page="/share/layout.jsp" flush="true">
    <jsp:param name="title" value="書籍情報登録"/>
    <jsp:param name="css" value="booksearch.css"/>
    <jsp:param name="style" value="common.css"/>
    <jsp:param name="content">
        <jsp:attribute name="value">
<!-- contents start -->


<%

	String title 			= (String)request.getParameter("title");
	String genre 			= (String)request.getParameter("genre");
	String publisher 		= (String)request.getParameter("publisher");
	String writer 			= (String)request.getParameter("writer");
	String content 			= (String)request.getParameter("content");
	String publication_date = (String)request.getParameter("publication_date");
	String isbn 			= (String)request.getParameter("isbn");
	String picture 			= (String)request.getParameter("picture");

	String title_redline 			= (String)request.getAttribute("title_redline");
	String genre_redline 			= (String)request.getAttribute("genre_redline");
	String publisher_redline 		= (String)request.getAttribute("publisher_redline");
	String writer_redline 			= (String)request.getAttribute("writer_redline");
	String publication_date_redline = (String)request.getAttribute("publication_date_redline");
	String isbn_redline 			= (String)request.getAttribute("isbn_redline");
	String picture_redline 			= (String)request.getAttribute("picture_redline");

	String error = (String)request.getAttribute("error");

	// 項目欄の内容が取得できなければ空白を設定
	if(title == null){
		title = "";
	}
	if(genre == null || genre.equals("選択")){
		genre = "選択";
	}
	if(publisher == null){
		publisher = "";
	}
	if(writer == null){
		writer = "";
	}
	if(content == null){
		content = "";
	}
	if(publication_date == null){
		publication_date = "";
	}
	if(isbn == null){
		isbn = "";
	}
	if(picture == null){
		picture = "";
	}
 %>
 <SCRIPT language='JavaScript'>
 function reset(){
 		title = "";
 		genre = "選択";
 		publisher = "";
 		writer = "";
 		content = "";
 		publication_date = "";
 		isbn = "";
 		picture = "";
}
 </SCRIPT>

<div>

<% if(error != null ){ %>
<p class="error_message">登録に必要な項目欄に未入力の項目があります</p>
	<% }%>

<!-- ======▼======入力確認処理追加【2013.10.17 yano】======▼====== -->
<%-- エラーメッセージが設定されていれば表示 --%>
<p class="error_message">
	<%
		@SuppressWarnings("unchecked")
		ArrayList<String> errorM = (ArrayList<String>)request.getAttribute("error_message");
		if(errorM != null && !errorM.equals("")){

			for( int i=0 ; i<errorM.size() ; i++ ){
	%>
				<%=errorM.get( i ) %><br />
	<%
			}
		}
	%>
</p>
<!-- ======▲======入力確認処理追加【2013.10.17 yano】======▲====== -->

<p>登録内容を入力して下さい</p>
<p><font color="#ff0000">（※）の付いている項目は必ず入力してください</font></p>
</div>

<form action="/Books/book/EntryServlet"  method="post">
<table class = "form_table">
 	<tr>
		<th>（※）タイトル</th>
<!-- タイトル入力フィールド変更	2013.10.17	矢野 -->
		<td><textarea name="title" cols="40" rows="2" class="<%= title_redline %>"><%= title %></textarea>
<%-- 		<input type="text" name="title"  value="<%= title %>"  class="<%= title_redline %>"size="80"/> --%>
		</td>
	</tr>
		<tr>
		<th>（※）著者名</th>
		<td><input type="text" name="writer"  value="<%= writer %>"  class="<%= writer_redline %>"size="40"/>
		</td>
	</tr>
		<tr>
		<th>（※）出版者</th>
		<td><input type="text" name="publisher"  value="<%= publisher %>"  class="<%= publisher_redline %>" size="40"/></td>
	</tr>
	<tr>
		<th>（※）ジャンル</th>
		<td>
				<select name="genre">
					<option value="<%= genre %>" class="<%= genre_redline %>"><%= genre %></option>
					<%
						selectMenu select = new selectMenu();
						Map<Integer,String> map = select.publisherShow();
						map = select.genreShow();
						for(Map.Entry<Integer, String> me : map.entrySet()) {
					%>
						<option value="<%= me.getValue() %>"><%= me.getValue() %></option>

					<% } %>
				</select>
				<% if(genre_redline != null ){ %>
				<span class="small red">※ジャンルを選択して下さい</span>
				<%}%>
			</td>
	</tr>
	<tr>
		<th>（※）ISBNコード</th>
		<td><input type="text" name="isbn"  value="<%= isbn %>"  class="<%= isbn_redline %>" size="40" maxlength="20"/> <span class="small">(※半角)</span></td>
	</tr>
	<tr>
		<th>（※）発行年月日</th>
		<td><input type="text" name="publication_date"  value="<%= publication_date %>"  class="<%= publication_date_redline %>" size="12" maxlength="10"/> <span class="small">記入例：2013-10-23 (※半角)</span></td>
	</tr>
		<tr>
		<th>画像ファイル名</th>
		<td><input type="text" name="picture"  value="<%= picture %>" size="40" maxlength="50" class="<%= picture_redline %>" /> <span class="small">(※半角)</span></td>
	</tr>
	<tr>
		<th>内容</th>
		<td><TEXTAREA name="content"  COLS="50" ROWS="5"><%= content %></TEXTAREA></td>
	</tr>

</table>
	<br>
	<div id  ="button">
	<input type="button" value="戻る" class="button" style="cursor:pointer" onClick="history.back(); return false;" />
	<input class = "button" type="submit"  value="確認" >
	</div>
	</form>


<!-- 	<form action="/Books/book/SearchServlet"  method="post"> -->
<!-- 	<div id  ="button"> -->
<!-- 	<input class = "button"  type="submit"  value="戻る"/> -->
<!-- 	</div> -->
<!-- 	</form> -->

<!-- 	<form action="/Books/book/userBookEntry.jsp"  method="post"> -->
<!-- 	<div id  ="button"> -->
<!-- 	<input class = "button"  type="submit"  value="やり直し"  onclick ='reset()'/> -->
<!-- 	</div> -->
<!-- 	</form> -->

<!-- contents end -->
        </jsp:attribute>
    </jsp:param>
</jsp:include>

